const path = require('path')
let alias = require('./alias.config');

const resolve = (dir) => path.join(__dirname, dir);

module.exports = {
    publicPath: '/',
    outputDir: '../server/src/main/resources/static',
    assetsDir: 'static',
    indexPath: 'index.html',
    runtimeCompiler: true,
    productionSourceMap: true,
    lintOnSave: process.env.NODE_ENV === 'development',
    devServer: {
        host: '127.0.0.1',
        port: process.env.VUE_APP_FRONT_END_PORT,
        https: false,
        proxy: {
            ['/blade-visual']: {
                target: process.env.VUE_APP_BACK_END_URL,
                changeOrigin: true,
                pathRewrite: {
                    '/blade-visual': ''
                }
            }
        },
    },
    configureWebpack: {
        name: "拖拽编辑器",
        resolve: alias.resolve
    },
    chainWebpack: config => {
        config.module
            .rule('svg')
            .exclude.add(resolve('src/assets/svg'))
            .end();
        config.module
            .rule('icons')
            .test(/\.svg$/)
            .include.add(resolve('src/assets/svg'))
            .end()
            .use('svg-sprite-loader')
            .loader('svg-sprite-loader')
            .options({
                symbolId: 'me-icon-[name]'
            })
            .end()
    },
}
